﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;
using System.Data;

namespace Interfaces.Tareas
{
    public partial class TareasPendientes : System.Web.UI.Page
    {
        string res,ci;
        int gestion;
        protected void Page_PreInit(object sender, EventArgs e)
        {


            if (Session["BuscarMaster"] != null)
            {
                this.MasterPageFile = (string)Session["BuscarMaster"];
            }
            else
            {
                this.MasterPageFile = "~/MasterPages/Default.Master";
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!User.Identity.IsAuthenticated)
                FormsAuthentication.RedirectToLoginPage();
            ci = Convert.ToString(DataBase.Miembro2.BDMiembro.DevolverMiembroPorUsuario(User.Identity.Name).CI);
            gestion = DateTime.Now.Year;
            DataList1.DataSource = Processes.Tareas.GestorTareas.ListaDeTareasPendientes(ci,gestion,false);
            DataList2.DataSource = Processes.Tareas.GestorTareas.ListaDeTareasPendientes(ci, gestion, true);
            DataList1.DataBind();
            DataList2.DataBind();
        }
        
        protected void Ver_Click(object sender, EventArgs e)
        {

        }

        protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e)
        {
            Label id = (Label)e.Item.FindControl("ID");
            if (e.CommandName == "Ver")
            {                
                Response.Redirect("/Tareas/VerTarea.aspx?Relacionado=" + false + "&ID=" + id.Text);             
            }
        }

        protected void DataList1_SelectedIndexChanged1(object sender, EventArgs e)
        {
           
        }

        protected void Ver2_Click(object sender, EventArgs e)
        {

        }

        protected void DataList2_ItemCommand(object source, DataListCommandEventArgs e)
        {
            Label id = (Label)e.Item.FindControl("ID");
            if (e.CommandName == "Ver")
            {
                Response.Redirect("/Tareas/VerTarea.aspx?Relacionado=" + true + "&ID=" + id.Text);
            }
        }

        protected void DataList2_SelectedIndexChanged1(object sender, EventArgs e)
        {

        }
    }
}